<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=UFT-8">
<title>终端管理</title>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<script src="../../hplus/js/jquery.min.js"></script>
<link rel="stylesheet" href="../../ztree/css/zTreeStyle/zTreeStyle.css" type="text/css">
<script type="text/javascript" src="../../ztree/js/jquery.ztree.core.js"></script>
<link rel="stylesheet" type="text/css" href="../../easyui/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="../../easyui/themes/icon.css">
<script type="text/javascript" src="../../easyui/jquery.easyui.min.js?1=1" charset="gbk"></script>
<style type="text/css">
	.tabs
	{
		font-family:微软雅黑;
		font-size:14px;
		height: 36px;
		background-color: rgb(224,236,255);
		width: 100%;
	}
	.tab-btn
	{
		float:left;
		margin-top:5px;
		line-height:30px;
		border: 1px solid rgb(186,219,234);
		margin-left:5px;
		height: 30px;
		padding-right: 5px;
		padding-left: 25px;
		border-top-left-radius:0.3em;
		border-top-right-radius:0.3em;
		cursor: pointer;
		color: rgb(26,110,187);
	}
	.tab-btn-active
	{
		border-bottom: 1px solid white;
	}
	
	.form-edit
	{
		border-collapse:collapse;
		width: 100%;
	}
	.form-edit td
	{
		background-color: rgb(241,241,239);
		border: 1px solid rgb(228,226,223);
		padding-left: 5px;
	}
	.btn
	{
		padding-left: 5px;
		padding-right: 5px;
		height: 30px;
		line-height: 30px;
		text-align: center;
		border-radius:5px;
		color: white;
		background-color: rgb(0,197,228);
		cursor: pointer;
		float: left;
		margin:5px 5px 5px 5px;
		font-weight: bold;
	}
	.btn:hover
	{
		background-color: rgb(0,170,228);
	}
	.icon-dandy{
		background:url('icons/1_close.png') no-repeat;
	}
	
</style>
</head>
<body class="easyui-layout">
	<div data-options="region:'center'" style="overflow-x:hidden;overflow-y:hidden;padding: 3px;">
		<div id="tt" class="easyui-tabs" style="width: 100%; height: 100%;overflow-x:hidden;overflow-y:hidden;">
			<div title="终端信息新建" style="padding: 3px">
				<form id="terminalForm">
					<table class="form-edit">
						<tr>
							<td width="10%;">
								终端品牌：
							</td>
							<td width="40%">
								<input id="brand" class="easyui-textbox" style="width:200px;height:32px">
							</td>
							<td width="10%;">
								终端型号：
							</td>
							<td width="40%">
								<input id="terminalVersion" class="easyui-textbox" style="width:200px;height:32px">
							</td>
						</tr>
						<tr>
							<td width="10%;">
								入网型号：
							</td>
							<td width="40%">
								<input id="netVersion" class="easyui-textbox" style="width:200px;height:32px">
							</td>
							<td width="10%;">
								<font color="red">*</font>MAC：
							</td>
							<td width="40%">
								<input id="mac" data-options="required:true" class="easyui-textbox" style="width:200px;height:32px">
							</td>
						</tr>
						<tr>
							<td width="10%;">
								上市年份：
							</td>
							<td width="40%">
								<input id="launchYear" class="easyui-textbox" style="width:200px;height:32px">
							</td>
							<td width="10%;">
								上市月份：
							</td>
							<td width="40%">
								<input id="launchMonth" class="easyui-textbox" style="width:200px;height:32px">
							</td>
						</tr>
						<tr>
							<td width="10%;">
								机身长度：
							</td>
							<td width="40%">
								<input id="length" class="easyui-textbox" style="width:200px;height:32px">
							</td>
							<td width="10%;">
								机身宽度：
							</td>
							<td width="40%">
								<input id="width" class="easyui-textbox" style="width:200px;height:32px">
							</td>
						</tr>
						<tr>
							<td width="10%;">
								机身厚度：
							</td>
							<td width="40%">
								<input id="thick" class="easyui-textbox" style="width:200px;height:32px">
							</td>
							<td width="10%;">
								机身重量：
							</td>
							<td width="40%">
								<input id="weight" class="easyui-textbox" style="width:200px;height:32px">
							</td>
						</tr>
						<tr>
							<td width="10%;">
								机身材质分类：
							</td>
							<td width="40%">
								<input id="bodyMaterialCatergory" class="easyui-textbox" style="width:200px;height:32px">
							</td>
							<td width="10%;">
								镜架材质分类：
							</td>
							<td width="40%">
								<input id="holderMaterialCatergory" class="easyui-textbox" style="width:200px;height:32px">
							</td>
						</tr>
						<tr>
							<td width="10%;">
								镜头材质分类：
							</td>
							<td width="40%">
								<input id="headerMaterialCatergory" class="easyui-textbox" style="width:200px;height:32px">
							</td>
							<td width="10%;">
								操作系统：
							</td>
							<td width="40%">
								<input id="operatingSystem" class="easyui-textbox" style="width:200px;height:32px">
							</td>
						</tr>
						<tr>
							<td width="10%;">
								操作系统版本：
							</td>
							<td width="40%">
								<input id="operatingSystemVersion" class="easyui-textbox" style="width:200px;height:32px">
							</td>
							<td width="10%;">
								ROM：
							</td>
							<td width="40%">
								<input id="rom" class="easyui-textbox" style="width:200px;height:32px">
							</td>
						</tr>
						<tr>
							<td width="10%;">
								RAM：
							</td>
							<td width="40%">
								<input id="ram" class="easyui-textbox" style="width:200px;height:32px">
							</td>
							<td width="10%;">
								最大存储扩展容量：
							</td>
							<td width="40%">
								<input id="maxExtCapacity" class="easyui-textbox" style="width:200px;height:32px">
							</td>
						</tr>
						<tr>
							<td width="10%;">
								主芯片:CPU品牌：
							</td>
							<td width="40%">
								<input id="cpuBrand" class="easyui-textbox" style="width:200px;height:32px">
							</td>
							<td width="10%;">
								主芯片:CPU频率：
							</td>
							<td width="40%">
								<input id="cpuFrequency" class="easyui-textbox" style="width:200px;height:32px">
							</td>
						</tr>
						<tr>
							<td width="10%;">
								主芯片:CPU核数：
							</td>
							<td width="40%">
								<input id="cpuCoreNum" class="easyui-textbox" style="width:200px;height:32px">
							</td>
							<td width="10%;">
								主芯片:CPU型号：
							</td>
							<td width="40%">
								<input id="cpuVersion" class="easyui-textbox" style="width:200px;height:32px">
							</td>
						</tr>
						<tr>
							<td width="10%;">
								摄像头数量：
							</td>
							<td width="40%">
								<input id="cameraNum" class="easyui-textbox" style="width:200px;height:32px">
							</td>
							<td width="10%;">
								摄像头像素：
							</td>
							<td width="40%">
								<input id="cameraPixel" class="easyui-textbox" style="width:200px;height:32px">
							</td>
						</tr>
						<tr>
							<td width="10%;">
								镜头尺寸：
							</td>
							<td width="40%">
								<input id="lensSize" class="easyui-textbox" style="width:200px;height:32px">
							</td>
							<td width="10%;">
								分辨率：
							</td>
							<td width="40%">
								<input id="screenFbl" class="easyui-textbox" style="width:200px;height:32px">
							</td>
						</tr>
						<tr>
							<td width="10%;">
								电池容量（mAh）：
							</td>
							<td width="40%">
								<input id="batteryCapacity" class="easyui-textbox" style="width:200px;height:32px">
							</td>
							<td width="10%;">
								待机时间（小时）：
							</td>
							<td width="40%">
								<input id="awaitRunTime" class="easyui-textbox" style="width:200px;height:32px">
							</td>
						</tr>
						<tr>
							<td width="10%;">
								可运行时间：
							</td>
							<td width="40%">
								<input id="availRunTime" class="easyui-textbox" style="width:200px;height:32px">
							</td>
							<td width="10%;">
								屏幕像素密度：
							</td>
							<td width="40%">
								<input id="screenDensity" class="easyui-textbox" style="width:200px;height:32px">
							</td>
						</tr>
						<tr>
							<td width="10%;">
								数据传输接口：
							</td>
							<td width="40%">
								<input id="dataTransInterface" class="easyui-textbox" style="width:200px;height:32px">
							</td>
							<td width="10%;">
								包装清单：
							</td>
							<td width="40%">
								<input id="packingList" class="easyui-textbox" style="width:200px;height:32px">
							</td>
						</tr>
						<tr>
							<td colspan="4">
								<div>
									<div id="save" class="btn" style="width: 50px;">提交</div>
									<div id="reset" class="btn" style="width: 50px;">重置</div>
								</div>
							</td>
						</tr>
					</table>
				</form>
			</div>
			<div title="终端信息管理" style="padding: 3px;overflow: hidden;">
				<div class="easyui-layout" data-options="fit:true">
					<div data-options="region:'north',border:false" style="height:56px">
						<form id="conditionForm">
							<table class="form-edit">
								<tr>
									<td width="10%;">
										终端型号：
									</td>
									<td width="40%">
										<input id="i_terminalVersion" class="easyui-textbox" style="width:200px;height:22px">
									</td>
									<td width="10%;">
										上市年份：
									</td>
									<td width="40%">
										<input id="i_launchYear" class="easyui-textbox" style="width:200px;height:22px">
									</td>
								</tr>
								<tr>
									<td width="10%;">
										CPU频率：
									</td>
									<td width="40%">
										<input id="i_cpuFrequency" class="easyui-textbox" style="width:200px;height:22px">
									</td>
									<td width="10%;">
										镜头分辨：
									</td>
									<td width="40%">
										<input id="i_screenFbl" class="easyui-textbox" style="width:200px;height:22px">
									</td>
								</tr>
								
							</table>
						</form>
					</div>
					<div data-options="region:'center',border:false">
						<table id="terminalGrid" class="easyui-datagrid"
								data-options="method:'get',rownumbers:true,
								toolbar:toolbar,pagination: true,fit:true,fitColumns:true">
							<thead>
								<tr>
									<th field="ck" checkbox="true"></th>
									<th data-options="field:'id',width:80,hidden:true">id</th>
									<th data-options="field:'terminalVersion',width:100">终端型号</th>
									<th data-options="field:'mac',width:100">MAC</th>
									<th data-options="field:'operatingSystemVersion',width:100">操作系统版本</th>
									<th data-options="field:'cpuVersion',width:100">CPU型号</th>
									<th data-options="field:'maxExtCapacity',width:100">最大存储扩展容量</th>
									<th data-options="field:'screenFbl',width:100">分辨率</th>
									<!-- <th data-options="field:'',width:100">部署应用</th>  -->
								</tr>
							</thead>
						</table>
					</div>
				</div>
			</div>
			<div title="终端信息修改" style="padding: 3px">
				<form id="updateForm">
					<table class="form-edit">
						<tr style="display: none;">
							<td>
								<input id="u_id" class="easyui-textbox" style="width:200px;height:32px">
							</td>
						</tr>
						<tr>
							<td width="10%;">
								终端品牌：
							</td>
							<td width="40%">
								<input id="u_brand" class="easyui-textbox" style="width:200px;height:32px">
							</td>
							<td width="10%;">
								终端型号：
							</td>
							<td width="40%">
								<input id="u_terminalVersion" class="easyui-textbox" style="width:200px;height:32px">
							</td>
						</tr>
						<tr>
							<td width="10%;">
								入网型号：
							</td>
							<td width="40%">
								<input id="u_netVersion" class="easyui-textbox" style="width:200px;height:32px">
							</td>
							<td width="10%;">
								MAC：
							</td>
							<td width="40%">
								<input id="u_mac" data-options="readonly:true" class="easyui-textbox" style="width:200px;height:32px">
							</td>
						</tr>
						<tr>
							<td width="10%;">
								上市年份：
							</td>
							<td width="40%">
								<input id="u_launchYear" class="easyui-textbox" style="width:200px;height:32px">
							</td>
							<td width="10%;">
								上市月份：
							</td>
							<td width="40%">
								<input id="u_launchMonth" class="easyui-textbox" style="width:200px;height:32px">
							</td>
						</tr>
						<tr>
							<td width="10%;">
								机身长度：
							</td>
							<td width="40%">
								<input id="u_length" class="easyui-textbox" style="width:200px;height:32px">
							</td>
							<td width="10%;">
								机身宽度：
							</td>
							<td width="40%">
								<input id="u_width" class="easyui-textbox" style="width:200px;height:32px">
							</td>
						</tr>
						<tr>
							<td width="10%;">
								机身厚度：
							</td>
							<td width="40%">
								<input id="u_thick" class="easyui-textbox" style="width:200px;height:32px">
							</td>
							<td width="10%;">
								机身重量：
							</td>
							<td width="40%">
								<input id="u_weight" class="easyui-textbox" style="width:200px;height:32px">
							</td>
						</tr>
						<tr>
							<td width="10%;">
								机身材质分类：
							</td>
							<td width="40%">
								<input id="u_bodyMaterialCatergory" class="easyui-textbox" style="width:200px;height:32px">
							</td>
							<td width="10%;">
								镜架材质分类：
							</td>
							<td width="40%">
								<input id="u_holderMaterialCatergory" class="easyui-textbox" style="width:200px;height:32px">
							</td>
						</tr>
						<tr>
							<td width="10%;">
								镜头材质分类：
							</td>
							<td width="40%">
								<input id="u_headerMaterialCatergory" class="easyui-textbox" style="width:200px;height:32px">
							</td>
							<td width="10%;">
								操作系统：
							</td>
							<td width="40%">
								<input id="u_operatingSystem" class="easyui-textbox" style="width:200px;height:32px">
							</td>
						</tr>
						<tr>
							<td width="10%;">
								操作系统版本：
							</td>
							<td width="40%">
								<input id="u_operatingSystemVersion" class="easyui-textbox" style="width:200px;height:32px">
							</td>
							<td width="10%;">
								ROM：
							</td>
							<td width="40%">
								<input id="u_rom" class="easyui-textbox" style="width:200px;height:32px">
							</td>
						</tr>
						<tr>
							<td width="10%;">
								RAM：
							</td>
							<td width="40%">
								<input id="u_ram" class="easyui-textbox" style="width:200px;height:32px">
							</td>
							<td width="10%;">
								最大存储扩展容量：
							</td>
							<td width="40%">
								<input id="u_maxExtCapacity" class="easyui-textbox" style="width:200px;height:32px">
							</td>
						</tr>
						<tr>
							<td width="10%;">
								主芯片:CPU品牌：
							</td>
							<td width="40%">
								<input id="u_cpuBrand" class="easyui-textbox" style="width:200px;height:32px">
							</td>
							<td width="10%;">
								主芯片:CPU频率：
							</td>
							<td width="40%">
								<input id="u_cpuFrequency" class="easyui-textbox" style="width:200px;height:32px">
							</td>
						</tr>
						<tr>
							<td width="10%;">
								主芯片:CPU核数：
							</td>
							<td width="40%">
								<input id="u_cpuCoreNum" class="easyui-textbox" style="width:200px;height:32px">
							</td>
							<td width="10%;">
								主芯片:CPU型号：
							</td>
							<td width="40%">
								<input id="u_cpuVersion" class="easyui-textbox" style="width:200px;height:32px">
							</td>
						</tr>
						<tr>
							<td width="10%;">
								摄像头数量：
							</td>
							<td width="40%">
								<input id="u_cameraNum" class="easyui-textbox" style="width:200px;height:32px">
							</td>
							<td width="10%;">
								摄像头像素：
							</td>
							<td width="40%">
								<input id="u_cameraPixel" class="easyui-textbox" style="width:200px;height:32px">
							</td>
						</tr>
						<tr>
							<td width="10%;">
								镜头尺寸：
							</td>
							<td width="40%">
								<input id="u_lensSize" class="easyui-textbox" style="width:200px;height:32px">
							</td>
							<td width="10%;">
								分辨率：
							</td>
							<td width="40%">
								<input id="u_screenFbl" class="easyui-textbox" style="width:200px;height:32px">
							</td>
						</tr>
						<tr>
							<td width="10%;">
								电池容量（mAh）：
							</td>
							<td width="40%">
								<input id="u_batteryCapacity" class="easyui-textbox" style="width:200px;height:32px">
							</td>
							<td width="10%;">
								待机时间（小时）：
							</td>
							<td width="40%">
								<input id="u_awaitRunTime" class="easyui-textbox" style="width:200px;height:32px">
							</td>
						</tr>
						<tr>
							<td width="10%;">
								可运行时间：
							</td>
							<td width="40%">
								<input id="u_availRunTime" class="easyui-textbox" style="width:200px;height:32px">
							</td>
							<td width="10%;">
								屏幕像素密度：
							</td>
							<td width="40%">
								<input id="u_screenDensity" class="easyui-textbox" style="width:200px;height:32px">
							</td>
						</tr>
						<tr>
							<td width="10%;">
								数据传输接口：
							</td>
							<td width="40%">
								<input id="u_dataTransInterface" class="easyui-textbox" style="width:200px;height:32px">
							</td>
							<td width="10%;">
								包装清单：
							</td>
							<td width="40%">
								<input id="u_packingList" class="easyui-textbox" style="width:200px;height:32px">
							</td>
						</tr>
						<tr>
							<td colspan="4">
								<div>
									<div id="update" class="btn" style="width: 50px;">提交</div>
								</div>
							</td>
						</tr>
					</table>
				</form>
			</div>
			<div title="终端信息批量导入" data-options="iconCls:'icon-dandy',closable:true"
				style="padding: 3px">
				<div class="easyui-layout" data-options="fit:true">
					<div data-options="region:'north',border:false" style="height:36px">
						<form id="uploadForm" action="${ctx}/terminal/exportTerminals" method="post" enctype="multipart/form-data">
							<table class="form-edit" style="width: 100%;">
								<tr>
									<td>
										终端批量导入（*.xlsx\*.xls）：
										<input id="file" class="easyui-filebox" name="file" data-options="prompt:'请选择文件...'" style="width:220px;">
										&nbsp;&nbsp;
										<a style="color: blue;cursor: pointer;" onclick="exportTerminals()">导入文件</a>
										&nbsp;&nbsp;
										<a style="color: blue;cursor: pointer;" onclick="downloadTemp()">下载模板</a>
									</td>
								</tr>
							</table>
						</form>
					</div>
					<div data-options="region:'center',border:false">
						<table id="terminalTempGrid" class="easyui-datagrid"
								data-options="method:'get',rownumbers:true,
								toolbar:toolbarTemp,fit:true,fitColumns:true">
							<thead>
								<tr>
									<th field="ck" checkbox="true"></th>
									<th data-options="field:'id',width:80,hidden:true">id</th>
									<th data-options="field:'terminalVersion',width:100">终端型号</th>
									<th data-options="field:'mac',width:100">MAC</th>
									<th data-options="field:'operatingSystemVersion',width:100">操作系统版本</th>
									<th data-options="field:'cpuVersion',width:100">CPU型号</th>
									<th data-options="field:'maxExtCapacity',width:100">最大存储扩展容量</th>
									<th data-options="field:'screenFbl',width:100">分辨率</th>
								</tr>
							</thead>
						</table>
					</div>
				</div>
			</div>
		</div>
	</div>
</body>
<script type="text/javascript">
$(document).ready(function() {
	
	$('#terminalGrid').datagrid('getPager').pagination({  
        pageSize: 15,//每页显示的记录条数，默认为10    
        pageList: [15, 30, 50],//可以设置每页记录条数的列表    
        beforePageText: '第',//页数文本框前显示的汉字    
        afterPageText: '页    共 {pages} 页',  
        displayMsg: '当前显示 {from} - {to} 条记录   共 {total} 条记录',  
        onSelectPage:function(pageNum, pageSize){
        	query(pageNum,pageSize);
        }
    }); 
	
	$('#tt').tabs('select', "终端信息管理");
	
	//查询
	query();
	
});


function downloadTemp() {
	window.location.href = "${ctx}/terminal/downloadTemp";
}

function exportTerminals(){
	$.messager.confirm('确认提示', '确定导入?', function(r){
		if (r){
			$.ajax({
				url : '${ctx}/terminal/exportTerminals',
				type : 'POST',
				cache : false,
				data : new FormData($('#uploadForm')[0]),
				processData : false,
				contentType : false
			}).done(function(res) {
				if(res.status=="1"){
					$.messager.alert('消息',res.msg,'info');
					$('#terminalTempGrid').datagrid('loadData', JSON.parse(res.data));
				}else{
					$.messager.alert('消息',res.msg,'error');
				}
			}).fail(function(res) {
				$.messager.alert('消息',"导入失败",'error');
			});
		}
	});
}

function query(pageNum,pageSize){
	if(!pageNum){
		pageNum = 1;
	}
	if(!pageSize){
		pageSize = 15;
	}
	$.ajax({
        type: "post",
        dataType: "json",
        url: '${ctx}/terminal/getTerminalList',
        data:{
        	pageNum:pageNum,
        	pageSize:pageSize,
        	terminalVersion:$("#i_terminalVersion").val(),
        	launchYear:$("#i_launchYear").val(),
        	cpuFrequency:$("#i_cpuFrequency").val(),
        	screenFbl:$("#i_screenFbl").val()
        },
        success: function (data) {
        	$('#terminalGrid').datagrid('loadData', data);
        },
		error:function(){
		}
    });
	
}

$("#save").on("click",function(){
	$.messager.confirm('确认提示', '确定保存?', function(r){
		if (r){
			$.ajax({
		        type: "post",
		        dataType: "json",
		        url: '${ctx}/terminal/addTerminal',
		        data:{
		        	brand:$("#brand").val(),
		        	terminalVersion:$("#terminalVersion").val(),
		        	netVersion:$("#netVersion").val(),
		        	launchYear:$("#launchYear").val(),
		        	launchMonth:$("#launchMonth").val(),
		        	mac:$("#mac").val(),
		        	width:$("#width").val(),
		        	length:$("#length").val(),
		        	thick:$("#thick").val(),
		        	color:$("#thick").val(),
		        	weight:$("#weight").val(),
		        	bodyMaterialCatergory:$("#bodyMaterialCatergory").val(),
		        	holderMaterialCatergory:$("#holderMaterialCatergory").val(),
		        	headerMaterialCatergory:$("#headerMaterialCatergory").val(),
		        	operatingSystem:$("#operatingSystem").val(),
		        	operatingSystemVersion:$("#operatingSystemVersion").val(),
		        	rom:$("#rom").val(),
		        	ram:$("#ram").val(),
		        	cpuBrand:$("#cpuBrand").val(),
		        	cpuFrequency:$("#cpuFrequency").val(),
		        	cpuCoreNum:$("#cpuCoreNum").val(),
		        	cpuVersion:$("#cpuVersion").val(),
		        	maxExtCapacity:$("#maxExtCapacity").val(),
		        	cameraNum:$("#cameraNum").val(),
		        	cameraPixel:$("#cameraPixel").val(),
		        	lensSize:$("#lensSize").val(),
		        	batteryCapacity:$("#batteryCapacity").val(),
		        	screenFbl:$("#screenFbl").val(),
		        	awaitRunTime:$("#awaitRunTime").val(),
		        	screenDensity:$("#screenDensity").val(),
		        	availRunTime:$("#availRunTime").val(),
		        	dataTransInterface:$("#dataTransInterface").val(),
		        	packingList:$("#packingList").val()
		        },
		        success: function (data) {
		        	$('#terminalForm').form('clear');
		        	query();
		        	$.messager.alert('消息',data.msg,'info');
		        },
				error:function(){
				}
		    });
		}
	});
});

$("#reset").on("click",function(){
	$('#userForm').form('clear');
});

function toUpdate(){
	var rows = $('#terminalGrid').datagrid('getSelections');
	if(rows.length < 1){
		$.messager.alert('消息','请选择一条记录','info');
		return;
	}
	if(rows.length > 1){
		$.messager.alert('消息','最多选择一条记录','info');
		return;
	}
	for(var i=0; i<rows.length; i++){
		$("#u_id").textbox('setValue', rows[i].id);
		$("#u_brand").textbox('setValue', rows[i].brand);
		$("#u_terminalVersion").textbox('setValue', rows[i].terminalVersion);
		$("#u_netVersion").textbox('setValue', rows[i].netVersion);
		$("#u_launchYear").textbox('setValue', rows[i].launchYear);
		$("#u_launchMonth").textbox('setValue', rows[i].launchMonth);
		$("#u_mac").textbox('setValue', rows[i].mac);
		$("#u_width").textbox('setValue', rows[i].width);
		$("#u_length").textbox('setValue', rows[i].length);
		$("#u_thick").textbox('setValue', rows[i].thick);
		$("#u_color").textbox('setValue', rows[i].color);
		$("#u_weight").textbox('setValue', rows[i].weight);
		$("#u_bodyMaterialCatergory").textbox('setValue', rows[i].bodyMaterialCatergory);
		$("#u_holderMaterialCatergory").textbox('setValue', rows[i].holderMaterialCatergory);
		$("#u_headerMaterialCatergory").textbox('setValue', rows[i].headerMaterialCatergory);
		$("#u_operatingSystem").textbox('setValue', rows[i].operatingSystem);
		$("#u_operatingSystemVersion").textbox('setValue', rows[i].operatingSystemVersion);
		$("#u_rom").textbox('setValue', rows[i].rom);
		$("#u_ram").textbox('setValue', rows[i].ram);
		$("#u_cpuBrand").textbox('setValue', rows[i].cpuBrand);
		$("#u_cpuFrequency").textbox('setValue', rows[i].cpuFrequency);
		$("#u_cpuCoreNum").textbox('setValue', rows[i].cpuCoreNum);
		$("#u_cpuVersion").textbox('setValue', rows[i].cpuVersion);
		$("#u_maxExtCapacity").textbox('setValue', rows[i].maxExtCapacity);
		$("#u_cameraNum").textbox('setValue', rows[i].cameraNum);
		$("#u_cameraPixel").textbox('setValue', rows[i].cameraPixel);
		$("#u_lensSize").textbox('setValue', rows[i].lensSize);
		$("#u_batteryCapacity").textbox('setValue', rows[i].batteryCapacity);
		$("#u_screenFbl").textbox('setValue', rows[i].screenFbl);
		$("#u_awaitRunTime").textbox('setValue', rows[i].awaitRunTime);
		$("#u_screenDensity").textbox('setValue', rows[i].screenDensity);
		$("#u_availRunTime").textbox('setValue', rows[i].availRunTime);
		$("#u_dataTransInterface").textbox('setValue', rows[i].dataTransInterface);
		$("#u_packingList").textbox('setValue', rows[i].packingList);
	}
	
	$('#tt').tabs('select', "终端信息修改");
}

$("#update").on("click",function(){
	if($("#u_id").val()==null || $("#u_id").val()==""){
		$.messager.alert('消息',"请选择修改记录",'info');
		return ;
	}
	
	$.messager.confirm('确认提示', '确定修改?', function(r){
		if (r){
			$.ajax({
		        type: "post",
		        dataType: "json",
		        url: '${ctx}/terminal/updateTerminal',
		        data:{
		        	id:$("#u_id").val(),
		        	brand:$("#u_brand").val(),
		        	terminalVersion:$("#u_terminalVersion").val(),
		        	netVersion:$("#u_netVersion").val(),
		        	launchYear:$("#u_launchYear").val(),
		        	launchMonth:$("#u_launchMonth").val(),
		        	mac:$("#u_mac").val(),
		        	width:$("#u_width").val(),
		        	length:$("#u_length").val(),
		        	thick:$("#u_thick").val(),
		        	color:$("#u_color").val(),
		        	weight:$("#u_weight").val(),
		        	bodyMaterialCatergory:$("#u_bodyMaterialCatergory").val(),
		        	holderMaterialCatergory:$("#u_holderMaterialCatergory").val(),
		        	headerMaterialCatergory:$("#u_headerMaterialCatergory").val(),
		        	operatingSystem:$("#u_operatingSystem").val(),
		        	operatingSystemVersion:$("#u_operatingSystemVersion").val(),
		        	rom:$("#u_rom").val(),
		        	ram:$("#u_ram").val(),
		        	cpuBrand:$("#u_cpuBrand").val(),
		        	cpuFrequency:$("#u_cpuFrequency").val(),
		        	cpuCoreNum:$("#u_cpuCoreNum").val(),
		        	cpuVersion:$("#u_cpuVersion").val(),
		        	maxExtCapacity:$("#u_maxExtCapacity").val(),
		        	cameraNum:$("#u_cameraNum").val(),
		        	cameraPixel:$("#u_cameraPixel").val(),
		        	lensSize:$("#u_lensSize").val(),
		        	batteryCapacity:$("#u_batteryCapacity").val(),
		        	screenFbl:$("#u_screenFbl").val(),
		        	awaitRunTime:$("#u_awaitRunTime").val(),
		        	screenDensity:$("#u_screenDensity").val(),
		        	availRunTime:$("#u_availRunTime").val(),
		        	dataTransInterface:$("#u_dataTransInterface").val(),
		        	packingList:$("#u_packingList").val(),
		        },
		        success: function (data) {
		        	query();
		        	$.messager.alert('消息',data.msg,'info');
		        },
				error:function(){
				}
		    });
		}
	});
});


function deleteTerminals(){
	var rows = $('#terminalGrid').datagrid('getSelections');
	if(rows.length < 1){
		$.messager.alert('消息','请选择一条记录','info');
	}
	
	var terminalIds = [];
	for(var i=0; i<rows.length; i++){
		terminalIds.push(rows[i].id);
	}
	
	$.messager.confirm('确认提示', '确定删除?', function(r){
		if (r){
			$.ajax({
		        type: "post",
		        dataType: "json",
		        url: '${ctx}/terminal/deleteTerminals',
		        data:{
		        	"terminalIds":terminalIds.join(",")
		        },
		        success: function (data) {
		        	if(data.status=='1'){
		        		$.messager.alert('消息',data.msg,'info');
		        		query();
		        	}
		        },
				error:function(){
				}
		    });
		}
	});
	
}

function confirmTempTerminals(){
	var rows = $('#terminalTempGrid').datagrid('getSelections');
	if(rows.length < 1){
		$.messager.alert('消息','请选择一条记录','info');
		return ;
	}
	
	var terminalList = new Array();

	for(var i=0; i<rows.length; i++){
		var terminal = new Object();
		
		terminal.brand = rows[i].brand;
		terminal.terminalVersion = rows[i].terminalVersion;
		terminal.netVersion = rows[i].netVersion;
		terminal.launchYear = rows[i].launchYear;
		terminal.launchMonth = rows[i].launchMonth;
		terminal.mac = rows[i].mac;
		terminal.width = rows[i].width;
		terminal.length = rows[i].length;
		terminal.thick = rows[i].thick;
		terminal.color = rows[i].color;
		terminal.weight = rows[i].weight;
		terminal.bodyMaterialCatergory = rows[i].bodyMaterialCatergory;
		terminal.holderMaterialCatergory = rows[i].holderMaterialCatergory;
		terminal.headerMaterialCatergory = rows[i].headerMaterialCatergory;
		terminal.operatingSystem = rows[i].operatingSystem;
		terminal.operatingSystemVersion = rows[i].operatingSystemVersion;
		terminal.rom = rows[i].rom;
		terminal.ram = rows[i].ram;
		terminal.cpuBrand = rows[i].cpuBrand;
		terminal.cpuFrequency = rows[i].cpuFrequency;
		terminal.cpuCoreNum = rows[i].cpuCoreNum;
		terminal.cpuVersion = rows[i].cpuVersion;
		terminal.maxExtCapacity = rows[i].maxExtCapacity;
		terminal.cameraNum = rows[i].cameraNum;
		terminal.cameraPixel = rows[i].cameraPixel;
		terminal.lensSize = rows[i].lensSize;
		terminal.batteryCapacity = rows[i].batteryCapacity;
		terminal.screenFbl = rows[i].screenFbl;
		terminal.awaitRunTime = rows[i].awaitRunTime;
		terminal.screenDensity = rows[i].screenDensity;
		terminal.availRunTime = rows[i].availRunTime;
		terminal.availRunTime = rows[i].dataTransInterface;
		terminal.dataTransInterface = rows[i].packingList;
		
		terminalList.push(terminal);
	}
	
	$.ajax({
        type: "post",
        dataType: "json",
        url: '${ctx}/terminal/confirmTempTerminals',
        data:{
        	"terminalListString":JSON.stringify(terminalList)
        },
        success: function (data) {
        	if(data.status=='1'){
        		query();
        		$.messager.alert('消息',data.msg,'info');
        		//成功了删除勾选的记录
                for(var i=0; i<rows.length; i++){
                	var index = $('#terminalTempGrid').datagrid('getRowIndex', rows[i]);//获取某行的行号          
                    $('#terminalTempGrid').datagrid('deleteRow', index);  
            	}
        	}else{
        		$.messager.alert('消息',data.msg,'error');
        	}
        },
		error:function(){
		}
    });
	
}

var toolbar = [{
	text:'查询',
	iconCls:'icon-search',
	handler:function(){
		query();
	}
},'-',{
	text:'重置',
	iconCls:'icon-undo',
	handler:function(){
		$('#conditionForm').form('clear');
	}
},'-',{
	text:'修改',
	iconCls:'icon-edit',
	handler:function(){
		toUpdate();
	}
},'-',{
	text:'删除',
	iconCls:'icon-remove',
	handler:function(){
		deleteTerminals();
	}
}];

var toolbarTemp = [ {
	text : '确定',
	iconCls : 'icon-ok',
	handler : function() {
		confirmTempTerminals();
	}
},'-'];

</script>
</html>
